package xc.com.cms.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import xc.com.cms.domain.CmsPage;
import xc.com.cms.request.QueryPageRequest;
import xc.com.cms.service.CmsPageService;
import xc.com.common.PageVo;
import xc.com.common.Result;


@RestController
@RequestMapping("/cmspage")
@CrossOrigin
public class CmsPageController {
    @Autowired
    private CmsPageService cmsPageService;

    @PostMapping("/findList/{page}/{size}")
    public PageVo<CmsPage> findList(@PathVariable("page") Integer page,@PathVariable("size") Integer size,@RequestBody QueryPageRequest queryPageRequest) {
        return cmsPageService.findList(page,size,queryPageRequest);
    }
    @PostMapping(value = "/add")
    public Result add(@RequestBody CmsPage cmsPage) {
        return cmsPageService.add(cmsPage);
    }

    @GetMapping("/get/{id}")
    public CmsPage findById(@PathVariable("id") String id) {
        return cmsPageService.getById(id);
    }

    @PutMapping("/edit/{id}")
    public Result edit(@PathVariable("id") String id,@RequestBody CmsPage cmsPage) {
        return cmsPageService.update(id,cmsPage);
    }

    @DeleteMapping("/delete/{id}")
    public Result delete(@PathVariable("id") String id) {
        return cmsPageService.delete(id);
    }

    @PostMapping("/postPage/{pageId}")
    public Result post(@PathVariable("pageId") String pageId) {
        return cmsPageService.postPage(pageId);
    }
}

